package com.flash.DayProcessing.mapper;

import com.flash.BusinessData.entity.DealData;
import com.flash.DayProcessing.entity.AssetValuationMjoinS;
import com.flash.InventoryManagement.entity.CashAccrualStock;
import com.flash.InventoryManagement.entity.SecurityAccrualStock;
import com.flash.TAManagement.entity.Ta;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Mapper
public interface assetValuationMapper {
    @Select("select s.securityId,s.initialState,\n" +
            " ROUND((nvl(s.quantity,0)*nvl(m.closingPrice,0)-money),2) as tootaIPrice from \n" +
            " (select * from securityStock where dateStock=#{dateTime} and fundId=#{fundId}) s " +
            " join (select * from marketData where time=#{dateTime}) m \n" +
            " on s.securityId=m.securityId")
     List<AssetValuationMjoinS>  selectStockarket(Map map);

    @Delete(" delete from  SecurityAccrualStock  where fundId=#{fundId} and dateAccrualStock=#{dateAccrualStock} \n" +
            " and businessState= #{businessState} and securityId=#{securityId} and securityType=#{securityType}")
    int delectSecurityAccrualStock(SecurityAccrualStock securityAccrualStock);

// 证券清算款
    @Select("select * from dealData where to_date(#{deteTime},'yyyy-MM-dd') < to_date(endTime,'yyyy-MM-dd') \n" +
            "and  to_date(#{deteTime},'yyyy-MM-dd') >= to_date(dealTime,'yyyy-MM-dd') and fundId=#{fundId}" )
    List<DealData> selectTransactionData(Map map);

// TA清算款
    @Select("select * from ta where to_date(#{deteTime},'yyyy-MM-dd') < to_date(endTime,'yyyy-MM-dd') \n" +
            "and  to_date(#{deteTime},'yyyy-MM-dd') >= to_date(dealTime,'yyyy-MM-dd') and fundId=#{fundId}")
    List<Ta> selectTa(Map map);
    //删除语句
    @Delete("delete from cashAccrualStock where cashId=#{cashId} and dateAccrualStock=#{dateAccrualStock}\n" +
            "and businessState=#{businessState}")
    int delectCashAccrualStock(CashAccrualStock cashAccrualStock);


}
